package wetalk.software.bupt.com.wetalk.BroadcastReceiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
import android.widget.Toast;

import com.google.gson.Gson;

import org.json.JSONException;
import org.json.JSONObject;

import wetalk.software.bupt.com.wetalk.DB.WeTalkDB;
import wetalk.software.bupt.com.wetalk.application.MyApplication;
import wetalk.software.bupt.com.wetalk.model.po.User;
import wetalk.software.bupt.com.wetalk.view.activity.UserInfoActivity;
import wetalk.software.bupt.com.wetalk.view.dialog.CustomDialog;

public class DelFriReceiver extends BroadcastReceiver {
    private static final String TAG="DelFriReceiver";
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d(TAG,"当前的线程为-->"+Thread.currentThread());

        SharedPreferences.Editor editor= MyApplication.getContext().getSharedPreferences("data",Context.MODE_PRIVATE).edit();
        SharedPreferences pref= MyApplication.getContext().getSharedPreferences("data",Context.MODE_PRIVATE);
        CustomDialog.getDialog(MyApplication.getContext(),"正在删除...").close();
        String content=intent.getStringExtra("content");
        String type=intent.getStringExtra("type");
        try {
            JSONObject json=new JSONObject(content);
            if(type.equals("delFriRes")){
                WeTalkDB.create(MyApplication.getContext()).delFri(json.getString("id"));
                editor.putString("isDel","yes");
                editor.commit();
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        abortBroadcast();
    }
}
